package com.aimei.security.authentication;

import com.aimei.security.entity.User;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import javax.security.auth.Subject;
import java.util.Collection;

/**
 * @author xiah
 * @date 2018/5/5 16:23
 */
public class UserAuthentication extends AbstractAuthenticationToken {
       private User user;

       public UserAuthentication(Collection<? extends GrantedAuthority> authorities) {
              super(authorities);
       }

       public UserAuthentication( User user) {
              super(null);
              this.user = user;
              this.setAuthenticated(false);
       }

       @Override
       public void setDetails(Object details) {
              super.setDetails(details);
       }

       @Override
       public Object getCredentials() {
              return null;
       }

       @Override
       public Object getPrincipal() {
              return this.user;
       }

       @Override
       public boolean implies(Subject subject) {
              return false;
       }
}
